<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // 1. pending  - 等待
        // 2. fulfilled - 成功
        // 3. rejected - 失败

        // 状态只能修改一次 - 不能重复修改！
        // 
        // pending -> fulfilled √
            // 执行resolve()函数
        // pending -> rejected √  
            // 执行reject()函数
            // 抛出throw 错误
        // pending -> pending 不需要变
        // fulfilled -> pending ×
        // rejected -> pending ×
        // fulfilled -> rejected ×
        // rejected -> fulfilled ×

        // 创建一个promise
        // 1. resolve() pending -> fulfilled
        // let p = new Promise((resolve,reject)=>{
        //     resolve(123);
        // });

        // console.log(p);

        // 2. reject()  pending -> rejected
        // let p = new Promise((resolve,reject)=>{
        //     reject(456);
        // });

        // console.log(p);
        // 3. throw异常 pending -> rejected
        // let p = new Promise((resolve,reject)=>{
        //    throw 'error'
        // });

        // console.log(p);
    </script>
</body>

</html>